import React from 'react';
import { View, StyleSheet, Image } from 'react-native';
import BaseView from './BaseView';

export default class Main extends BaseView {
  static navigationOptions = () => ({
    header: null
  });

  constructor(props) {
    super(props);
    this.state = {
      ...this.BaseState
    };
  }

  componentDidMount() {
    READ_CACHE('sessionId')
      .then((res) => {
        res ? this.replace('Home') : this.replace('Login');
      })
      .catch(() => {
        this.replace('Login');
      });
  }

  render() {
    return (
      <View style={styles.container}>
        {/* <Image style={styles.backgroundImage} source={require('../assets/images/timg.jpeg')} /> */}
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1
  },
  backgroundImage: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    width: null,
    height: null,
    // 不加这句，就是按照屏幕高度自适应
    // 加上这几，就是按照屏幕自适应
    // resizeMode:Image.resizeMode.contain,
    // 祛除内部元素的白色背景
    backgroundColor: 'rgba(0,0,0,0)'
  }
});
